package com.admin.service;

import com.admin.dbdao.StatisticsAdminDao;
import com.client.bean.FeedBack;
import com.data.util.CheckDataUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 统计管理
 *
 * @author:HingLo
 * @create 2017-10-13 15:18
 **/
@Service
public class StatisticsAdminService {


    @Autowired
    private StatisticsAdminDao statisticsAdminDao;


    public List<FeedBack> findFeedbackService() {
        return statisticsAdminDao.findFeedbackDao();
    }

    public List<?> findReportService() {
        return statisticsAdminDao.findReportDao();
    }

    /**
     * @param id
     * @param type o:举报 1：反馈
     * @return
     */
    public boolean signInfoStateService(String id, int type) {
        if (!CheckDataUtils.stringUtilsID(id))
            return false;
        id = id.trim();
        if (type == 0 && CheckDataUtils.stringUtilsID(id)) {
            return statisticsAdminDao.updateReportInfoStateDao(id);

        } else if (type == 1 && CheckDataUtils.stringUtilsID(id)) {
            return statisticsAdminDao.updateFeedbackInfoStateDao(id);

        }
        return false;
    }

    /**
     * 删除信息
     *
     * @param id
     * @param type 0:举报 1：反馈
     * @return
     */
    public boolean delInfoStateService(String id, int type) {

        if (type == 0 && CheckDataUtils.stringUtilsID(id)) {
            id = id.trim();
            return statisticsAdminDao.deleteReportInfoStateDao(id);

        } else if (type == 1 && CheckDataUtils.stringUtilsID(id)) {
            id = id.trim();
            return statisticsAdminDao.deleteFeedbackInfoStateDao(id);

        }
        return false;
    }
}
